import UIKit

class DWKeyboardTool: UIView {
    
    lazy var preBtn: UIButton = {
        let btn = UIButton.init(frame: CGRect.init(x: 10, y: 7, width: 30, height: 30))
        btn.setTitle("↑", for: .normal)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 20)
        btn.setTitleColor(UIColor.systemBlue, for: .normal)
        btn.setTitleColor(UIColor.systemGray, for: .disabled)
        self.addSubview(btn)
        return btn
    }()
    
    lazy var nextBtn: UIButton = {
        let btn = UIButton.init(frame: CGRect.init(x: 50, y: 7, width: 30, height: 30))
        btn.setTitle("↓", for: .normal)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 20)
        btn.setTitleColor(UIColor.systemBlue, for: .normal)
        btn.setTitleColor(UIColor.systemGray, for: .disabled)
        self.addSubview(btn)
        return btn
    }()
    
    lazy var finishBtn: UIButton = {
        let btn = UIButton.init(frame: CGRect.init(x: self.frame.size.width - 60, y: 8, width: 50, height: 28))
        btn.setTitle("完成", for: .normal)
        btn.titleLabel?.font = UIFont.init(name: "PingFangSC-Semibold", size: 16)
        btn.setTitleColor(UIColor.systemBlue, for: .normal)
        btn.setTitleColor(UIColor.systemGray, for: .disabled)
        self.addSubview(btn)
        return btn
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.init(red: 1, green: 1, blue: 1, alpha: 0.9)
        addFunction()
    }
    
    func addFunction() {
        preBtn.addTarget(self, action: #selector(preFunc), for: .touchUpInside)
        nextBtn.addTarget(self, action: #selector(nextFunc), for: .touchUpInside)
        finishBtn.addTarget(self, action: #selector(finishFunc), for: .touchUpInside)
    }
    
    @objc func preFunc() {
        DWKeyboardManage.default.dw_preResponder()
    }
    
    @objc func nextFunc() {
        DWKeyboardManage.default.dw_nextResponder()
    }
    
    @objc func finishFunc() {
        DWKeyboardManage.default.dw_resignFirstResponder()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
